package com.greenant.store.bean;

import com.avos.avoscloud.AVACL;
import com.avos.avoscloud.AVClassName;
import com.avos.avoscloud.AVObject;
import com.avos.avoscloud.AVRelation;
import com.avos.avoscloud.AVRole;

@AVClassName(AntAVObject.CLASS_HOMEPAGEIMAGEITEMS)
public class GoodsRecommend extends AntAVObject {
		
	public static final String ATTR_USRID ="usrId";
	public static final String ATTR_TITLE ="title";
	public static final String ATTR_SECTIONNUM ="sectionNum";
	public static final String ATTR_SHOWINDEX ="showIndex";
	public static final String ATTR_IMAGEURL ="image";
	public static final String ATTR_IMAGESTYLE="imageStyle";
	public static final String ATTR_LIST="list";
	public static final String ATTR_STOREID="storeId";
	
    private AntGoods goods;
	
	private AVRole customRole;

	public GoodsRecommend() {
		super();			
		setAccessCtrl();
	}
	
	public GoodsRecommend(String str) {
		super(str);
		setAccessCtrl();		
	}
	
	public String getStoreId() {
		return this.getString(ATTR_STOREID);
	}
	
	public void setStoreId(String storeId) {
		this.put(ATTR_STOREID, storeId);
	}
	
	public String getImageStyle() {
		return this.getString(ATTR_IMAGESTYLE);
	}

	public void setImageStyle(String tag) {
		this.put(ATTR_IMAGESTYLE, tag);
	}
	
	public String getImageUrl()
	{
		try {
			return this.getAVFile(ATTR_IMAGEURL).getUrl();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
	public void setImageUrl(String tag)
	{
		this.put(ATTR_IMAGEURL,tag);
	}
	
	public int getSectionNum()
	{
		try {
			return Integer.parseInt(this.getString(ATTR_SECTIONNUM));
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		return 0;
	}
	public void setSectionNum(int tag)
	{
		this.put(ATTR_SECTIONNUM,tag);
	}
	
	public int getShowIndex()
	{
		try {
			return this.getNumber(ATTR_SHOWINDEX).intValue();
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		return 0;
	}
	
	public void setShowIndex(int tag)
	{
		this.put(ATTR_SHOWINDEX,tag);
	}
	
	public String getTitle()
	{
		return this.getString(ATTR_TITLE);
	}
	public void setTitle(int tag)
	{
		this.put(ATTR_TITLE,tag);
	}
	
	
	public AVRelation<AVObject> getList()
	{
		return this.getRelation(ATTR_LIST);
	}
	
	public GoodsRecommend getInstance()
	{
		return this;
	}
	public String getUserId() {
		return this.getString(ATTR_USRID);
	}

	private void setUserId(String userId) {
		this.put(ATTR_USRID,userId);
	}
	

	
	private int setAccessCtrl() {
		
		acl = new AVACL();
		acl.setPublicReadAccess(true);//�˴����õ��������˵Ŀɶ�Ȩ��
        acl.setPublicWriteAccess(true);
        this.setACL(acl);

		return 0;
	}

	public AntGoods getAntGoods() {
		return goods;
	}

	public void setAntGoods(AntGoods mgoods) {
		this.goods = mgoods;
	}
	
}
